package com.tentcoo.core.command.demo;

import com.tentcoo.core.command.CommandHandler;
import com.tentcoo.util.AssertUtils;

/**
 * 命令处理器Demo，计算 n! 。
 * 
 * @author Allenz
 * @since 0.0.1-SNAPSHOT
 * 
 */
public class CommandHandlerDemo extends CommandHandler<CommandDemo, Long> {

	@Override
	public Long execute(CommandDemo command) {
		int n = command.getN();

		AssertUtils.isTrue(n > 0);

		long result = 1;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	}

}
